package main

import (
	"encoding/json"
	"fmt"
	"sync"
)

func main() {
	var (
		commonTag = sync.Map{}
		laterData = sync.Map{}
		whiteList = sync.Map{}
	)

	res := GetData()
	fmt.Printf("res = %+v\n", res)

	bytes, _ := json.Marshal(res)
	fmt.Println(string(bytes))

	if res.Data.CommonTag != nil {
		for k, v := range res.Data.CommonTag {
			commonTag.Store(k, v)
		}
	}

	if res.Data.LaterWillCompensate != nil {
		for k, v := range res.Data.LaterWillCompensate {
			laterData.Store(k, v)
		}
	}

	if res.Data.WhiteList != nil {
		for k, v := range res.Data.WhiteList {
			whiteList.Store(k, v)
		}
	}

	commonTag.Range(func(key, value interface{}) bool {
		fmt.Println(key)
		fmt.Println(value)
		return true
	})

	laterData.Range(func(key, value interface{}) bool {
		fmt.Println(key)
		fmt.Println(value)
		if data, ok := value.(LaterData); ok {
			fmt.Println("data = ", data.Text)
		}
		return true
	})

	whiteList.Range(func(key, value interface{}) bool {
		fmt.Println(key)
		fmt.Println(value)
		return true
	})

	data, ok := laterData.Load("天猫1")
	fmt.Println(data, ok)

}
